package com.cqupt.entity;

import com.cqupt.command.Command;
import com.cqupt.utils.CommandFactor;

public class receiver {
	private String com;
	public receiver(String com) {
		this.com = com;
	}
	public String run(){
		//上一次命令的结果
		String result = null;
		String[] commands = com.split("\\|");
		for (int i=0; i<commands.length; i++) {
			String commandString = commands[i];
			Command command = CommandFactor.getCommand(commandString,result);
			if (command == null) {
				result = "不能识别的命令";
			} else {
				result = command.run();
			}
		}
		return result;
	}
}
